package test_activiti;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.activiti.engine.form.FormProperty;
import org.activiti.engine.form.TaskFormData;
import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.task.Task;
import org.activiti.engine.test.ActivitiTestCase;
import org.activiti.engine.test.Deployment;

public class 测试流程的基本信息 extends ActivitiTestCase {

	//可以用逗号分隔开要部署的bpmn
	@Deployment(resources = {"bgApp1.bpmn"})
	public void testMe() {
		    ProcessInstance pi = runtimeService.startProcessInstanceByKey("bgApp1");
		    String piId = pi.getId();

		    Task task = taskService.createTaskQuery().taskAssignee("yw").includeTaskLocalVariables().singleResult();
		    System.out.println("formkey = "+task.getFormKey());
		    Map<String,Object> vmap = new HashMap<String,Object>();
		    vmap.put("next","reject");

		    pi = runtimeService.createProcessInstanceQuery().processInstanceId(piId).singleResult();//要重新查过流程，不然获取值为null
		    System.out.println("taskName = "+task.getName()
		    +"\ttask_id="+task.getId()
		    +"\ttask_def_key="+task.getTaskDefinitionKey()
		    + "\tproce_def_key="+pi.getProcessDefinitionKey()
		    + "\tproce_def_id="+pi.getProcessDefinitionId()
		    + "\tproce_def_name="+pi.getProcessDefinitionName()
		    );
		    taskService.complete(task.getId(),vmap);

		    ActivitiUtils.printProcInstHistory(historicDataService,runtimeService,piId);

	}
}
